package com.linln.modules.member.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.linln.common.constant.StatusConst;
import com.linln.modules.member.domain.MemberShare;


/**
 * @author hct
 * @date 2019/09/12
 */
public interface MemberShareRepository extends JpaRepository<MemberShare, Long> {
	
	   @Transactional
	   @Query(value="select *  from member_share where member_id = ?1 and type =?2 and typeId=?3",nativeQuery = true)
	   public MemberShare getByMemberIdAndTypeId(Long memberId,Integer type,Long messageId);
	   
	   

	   @Query(value="select count(*) from member_share  where member_id = ?1  and to_days(create_date) = to_days(now()) ",nativeQuery=true)
	   public long getDayAddCount(Long userId);
	   
	   @Modifying
       @Transactional
	   @Query(value="delete from member_share  where member_id = ?1 ",nativeQuery=true)
	   public Integer deleteByMemberId(Long memberId);
	    

}